package com.odhixon.volarme;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import com.odhixon.volarme.gui.OpcionesForm;
import com.odhixon.volarme.persistence.Persistence;
import com.sun.lwuit.Display;
import com.sun.lwuit.Form;
import com.sun.lwuit.plaf.UIManager;
import com.sun.lwuit.util.Resources;
import javax.microedition.midlet.*;

/**
 * VolarME.
 * @author Ariel Aguirre <odhixon@gmail.com>
 */
public class VolarME extends MIDlet {
    private Form activeForm;

    public static Resources getResource() throws Exception {
        return Resources.open("/volarmeTheme.res");
    }

    public VolarME() {
        Display.init(this);
        try {
            Resources resources = VolarME.getResource();
            UIManager.getInstance().setThemeProps(resources.getTheme(resources.getThemeResourceNames()[0]));
        }
        catch (Exception e) {
            e.printStackTrace();
        }
        Persistence.getInstance().open();
        OpcionesForm opcionesForm = OpcionesForm.getInstance();
        opcionesForm.setMidlet(this);
        activeForm = opcionesForm;
    }

    public void startApp() {
        activeForm.show();
    }

    public void pauseApp() {
        activeForm = Display.getInstance().getCurrent();
    }

    public void destroyApp(boolean unconditional) {
        Persistence.getInstance().close();
    }
}
